package com.maimao.model.user;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.maimao.model.goods.Brand;
import com.maimao.model.user.sys.Role;
import lombok.*;

import javax.annotation.RegEx;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2020/11/28 10:57 上午
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("mm_enterprise")
public class Enterprise implements Serializable {
    private static final long serialVersionUID = -7966474189965229520L;

    @TableId(type = IdType.AUTO)
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;

    @NotBlank(message = "请输入邮箱")
    @Email(message = "邮箱格式不正确")
    private String email;

    @NotBlank(message = "请填写密码")
    private String password;

    @TableField("legal_person")
    @NotBlank(message = "请填写法人姓名")
    private String legalPerson;

    @TableField("id_number")
    @NotBlank(message = "请填写法人身份证")
    private String idNumber;

    @TableField("company_name")
    @NotBlank(message = "请填写企业名称")
    private String companyName;

    /**
     * 社会信用代码(注册号)
     */
    @TableField("social_code")
    @NotBlank(message = "请填写企业社会信用代码")
    private String socialCode;

    /**
     * 1 中国大陆 2中国香港 3中国澳门 4中国台湾
     */
    @TableField("legal_place")
    @NotNull(message = "请填写企业归属地")
    private Integer legalPlace;

    /**
     * 营业执照照片
     */
    @TableField("business_license")
    @NotBlank(message = "请上传营业证书")
    private String businessLicense;

    /**
     * 身份-正面
     */
    @TableField("id_url_front")
    private String idUrlFront;

    /**
     * 身份证-背面
     */
    @TableField("id_url_back")
    private String idUrlBack;

    /**
     * 身份证类型 1二代 0临时
     */
    @TableField("id_card_type")
    @NotNull(message = "请选择身份证类型")
    private Integer idCardType;

    /**
     * 银行开户人姓名
     */
    @TableField("account_holder")
    @NotBlank(message = "请填写银行开户人姓名")
    private String accountHolder;

    /**
     * 开户行 支行id 与 banks表的sub_branch_id关联
     */
    @TableField("sub_bank_id")
    @NotBlank(message = "请选择开户行")
    private String subBankId;

    @TableField(exist = false)
    private String subBankName;

    /**
     * 对公银行账号
     */
    @TableField("bank_number")
    @NotBlank(message = "请填写对公银行账号")
    private String bankNumber;

    @NotBlank(message = "请填写对公手机号")
    @Pattern(regexp = "^((13[0-9])|(14[0,1,4-9])|(15[0-3,5-9])|(16[2,5,6,7])|(17[0-8])|(18[0-9])|(19[0-3,5-9]))\\d{8}$", message = "手机号格式不正确")
    private String mobile;

    /**
     * 填写人身份 1 法人 0代理人
     */
    @TableField("fill_type")
    @NotNull(message = "请选择填写人身份")
    private Integer fillType;

    /**
     * 代理人身份证-正面
     */
    @TableField("proxy_user_front")
    private String proxyUserFront;

    /**
     * 代理人身份证-背面
     */
    @TableField("proxy_user_back")
    private String proxyUserBack;

    /**
     * 委托书-图片
     */
    @TableField("comission")
    private String comission;

    @TableField("shop_status")
    private Integer shopStatus;

    @TableField("fail_reason")
    private String failReason;

    @TableField(exist = false)
    private Brand brand;

    @TableField(exist = false)
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long shopId;

    @TableField(exist = false)
    private String code;


    @TableField(exist = false)
    private List<Role> roleList;

    @Override
    public String toString() {
        return "Enterprise{" +
                "id=" + id +
                ", email='" + email + '\'' +
                ", password='" + password + '\'' +
                ", legalPerson='" + legalPerson + '\'' +
                ", idNumber='" + idNumber + '\'' +
                ", companyName='" + companyName + '\'' +
                ", socialCode='" + socialCode + '\'' +
                ", legalPlace=" + legalPlace +
                ", businessLicense='" + businessLicense + '\'' +
                ", idUrlFront='" + idUrlFront + '\'' +
                ", idUrlBack='" + idUrlBack + '\'' +
                ", idCardType=" + idCardType +
                ", accountHolder='" + accountHolder + '\'' +
                ", subBankId='" + subBankId + '\'' +
                ", bankNumber='" + bankNumber + '\'' +
                ", mobile='" + mobile + '\'' +
                ", fillType=" + fillType +
                ", proxyUserFront='" + proxyUserFront + '\'' +
                ", proxyUserBack='" + proxyUserBack + '\'' +
                ", comission='" + comission + '\'' +
                '}';
    }
}
